package com.google.jguery.client.query;

import com.google.jguery.client.common.FieldText;
import com.google.jguery.client.common.TermPostings;
import com.google.jguery.client.index.DocReader;
import com.google.jguery.client.index.Index;
import com.google.jguery.client.index.TermReader;

public class Searcher {

	TermReader termReader;
	DocReader docReader;
	int docCountAll;
	
	public Searcher() {	
	}
	
	public Searcher(Index index) {
		termReader = index.getTermReader();
		docReader = index.getDocReader();
	}
	
	public void setIndex(Index index) {
		termReader = index.getTermReader();
		docReader = index.getDocReader();
	}
	
	public void setDocCountAll(int docCountAll) {
		this.docCountAll = docCountAll;
	}
	
	public Searcher(Index index, int docCountAll) {
		termReader = index.getTermReader();
		docReader = index.getDocReader();
		this.docCountAll = docCountAll;
	}
	
	public int getDocCount(FieldText ft) {
		return termReader.getDocCount(ft);
	}
	
	public TermPostings getPostings(FieldText ft) {
		return termReader.getPostings(ft);
	}
	
	public boolean contains(FieldText ft) {
		return termReader.contains(ft);
	}

	public int getDocCountAll() {
		return docCountAll;
	}
}
